@echo off
chcp 65001 >nul
echo ========================================
echo    API Router Startup Script
echo ========================================
echo.
echo Starting API Router Server...
echo Server URL: http://localhost:3001
echo.
echo Press Ctrl+C to stop server
echo ========================================
echo.

REM Check if Node.js is installed
node --version >nul 2>&1
if %errorlevel% neq 0 (
    echo Error: Node.js not found
    echo Please install Node.js: https://nodejs.org/
    pause
    exit /b 1
)

REM Check if dependencies are installed
if not exist "node_modules" (
    echo Installing dependencies...
    npm install
    if %errorlevel% neq 0 (
        echo Dependency installation failed
        pause
        exit /b 1
    )
    echo Dependencies installed successfully
    echo.
)

REM Start server
echo Starting API Router Server...
node src/main/server.js

REM If server exits unexpectedly
echo.
echo Server stopped
pause